<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<% String path = request.getContextPath();%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>等你回家</title>
    <!-- Favicon -->
    <link href="<%=path %>/web/index/css/style.css" rel="stylesheet" type="text/css" media="all" />
    <link rel="icon" href="<%=path%>/web/static/images/favicon.png" type="image/png" sizes="32x32">
    <link href="<%=path%>/web/index/css/inc.css" rel="stylesheet" type="text/css" media="all" />

    <link rel="stylesheet" href="<%=path%>/web/static/css/bootstrap.min.css">
    <link rel="stylesheet" href="<%=path%>/web/static/css/style.css">

</head>

<body>
<!--header-start -->
<div class="banner-in1">
    <%--<div class="container1">
        <c:if test="${param.lostTypeId eq 3}">
            <h6>寻亲登记 / <span>流浪乞讨</span></h6>
        </c:if>
        <c:if test="${param.lostTypeId eq 4}">
            <h6>寻亲登记 / <span>其他寻家</span></h6>
        </c:if>
        <c:if test="${param.lostTypeId eq 5}">
            <h6>寻亲登记 / <span>游子归家</span></h6>
        </c:if>
    </div>--%>
</div>
<!--header-->
<div class="header1">
    <div class="container1">
        <div class="logo1">
            <a href="index.html"><img src="<%=path %>/web/index/images/logo.png" alt=" " /></a>
        </div>
        <div class="top-nav1">
            <span class="menu1"> </span>
            <ul>
                <li class="active" ><a href="${pageContext.request.contextPath}/web/index" class="scroll">首页</a></li>
                <li><a href="<%=path %>/web/information/chooseType" class="scroll">你在哪儿</a></li>
                <li><a href="<%=path %>/web/information/informationList?lostTypeId=0" class="scroll">我想回家</a></li>
                <li><a href="<%=path %>/web/blogger/blog" class="scroll">日志论坛</a></li>
                <li><a href="<%=path %>/web/task/releaseTask" class="scroll">任务列表</a></li>
                <c:if test="${empty(sessionScope.userinfo)}" var="result">
                    <li><a href="<%=path %>/web/userinfo/register" class="scroll">注册</a>|<a href="<%=path %>/web/userinfo/login" class="scroll">登录</a></li>
                </c:if>
                <c:if test="${not result}">
                    <li><a href="<%=path%>/web/userinfo/applyVolunteer" class="scroll">加入我们</a></li>
                    <c:if test="${(sessionScope.userinfo.username eq '')||(sessionScope.userinfo.username eq NULL)}" var="result">
                        <span style="color:white">欢迎<a href="<%=path %>/web/userinfo/index" style="color: white" href="">${sessionScope.userinfo.phone}</a></span>
                    </c:if>
                    <c:if test="${not result}">
                        <span style="color:white">欢迎<a href="<%=path %>/web/userinfo/index" style="color: white" href="">${sessionScope.userinfo.username}</a></span>
                    </c:if>
                    <span style="color: white">|</span>

                    <span style="color:white"><a style="color: white" href="<%=path %>/web/userinfo/logout">注销</a></span>
                    <span style="color: white">|</span>
                    <label><img style="width:30px;height: 30px" src="<%=path %>/web/uploadImages/${sessionScope.userinfo.pic}"></label>
                </c:if>
            </ul>

        </div>
        <div class="clearfix1"> </div>
    </div>
</div>



<main class="main-content-area clearfix">
    <div class="post-job-area pb-100 pt-100">
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <div class=" post-form form-bg">
                        <div class="info-title mb-3">
                            <h3>发布日志</h3>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <c:if test="${empty requestScope.journal}" var="result">
                                    <form action="${pageContext.request.contextPath}/web/blogger/addlog" method="post" id="registers" enctype="multipart/form-data">
                                    <div class="form-row">
                                        <div class="form-group col-md-12">
                                            <label>&nbsp;输入标题:</label>
                                            <input type="hidden" name="userinfoId" value="${sessionScope.userinfo.id}" />
                                            <input style="width: 100%;display: block;border: 2px solid #e8ecec;padding: 7px 10px;border-radius: 8px;" placeholder="请输入日志标题" type="text" name="title" id="titles" class="tit"><br><span id="biaotiss"></span>
                                        </div>
                                    </div>
                                    <div class="form-row">
                                        <div class="form-group col-md-12">
                                            <label >&nbsp;内容:</label>
                                            <textarea id="info" name="info" rows="3" class="texts"></textarea><br>
                                            <span id="neirongs"></span>
                                        </div>
                                    </div>
                                    <div class="form-row">
                                        <div class="form-group col-md-12">
                                            <label style="float: left">&nbsp;上传照片:&nbsp;</label>
                                            <input style="float: left" type="file" id="pic" name="pic1">
                                            <span style="color:red;" id="pics"></span>
                                        </div>
                                    </div>
                                    <!-- 显示图片的DIV-->
                                    <div style="border:1px solid black; width: 250px;height:200px;margin-bottom: 10px;">
                                        <img style="width: 248px;height: 198px;" id="showPic" >
                                    </div>
                                    <button type="submit" class="btn btn-primary job-post-btn btn-lg btn-block " id="addBtn">发布</button>
                                </form>
                                </c:if>
                                <c:if test="${not result}" var="result">
                                    <form action="${pageContext.request.contextPath}/web/blogger/updateByJournalId" method="post" id="registers" enctype="multipart/form-data">
                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label>&nbsp;输入标题:</label>
                                                <input type="hidden" name="id" value="${requestScope.journal.id}">
                                                <input style="width: 100%;display: block;border: 2px solid #e8ecec;padding: 7px 10px;border-radius: 8px;" placeholder="请输入日志标题" type="text" name="title" id="titles" class="tit" value="${requestScope.journal.title}"><br><span id="biaotiss"></span>
                                            </div>
                                        </div>
                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label >&nbsp;内容:</label>
                                                <textarea id="info" name="info" rows="3" class="texts">${requestScope.journal.info}</textarea><br>
                                                <span id="neirongs"></span>
                                            </div>
                                        </div>
                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label style="float: left">&nbsp;上传照片:&nbsp;</label>
                                                <input style="float: left" type="file" id="pic" name="pic1">
                                                <span style="color:red;" id="pics"></span>
                                            </div>
                                        </div>
                                        <!-- 显示图片的DIV-->
                                        <div style="border:1px solid black; width: 250px;height:200px;margin-bottom: 10px;">
                                            <c:if test="${empty requestScope.journal.pics}" var="journalPic">
                                                <img style="width: 248px;height: 198px;" id="showPic" >
                                            </c:if>
                                            <c:if test="${not journalPic}">
                                                <img style="width: 248px;height: 198px;" id="showPic" src="<%=path %>/web/userinfo/img/journalImages/${journal.pics}">
                                            </c:if>
                                        </div>
                                        <button type="submit" class="btn btn-primary job-post-btn btn-lg btn-block " id="addBtn">发布</button>
                                    </form>
                                </c:if>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</main>
<!--footer-area-start -->
<footer>
    <div class="footer" style="height: 230px;">
        <div class="container" style="margin-top: -40px;">
            <p style="font-size: 15px;"><span style="font-size: 20px;">等你回家</span><span >邮箱:1111111@163.com</span> 电话:0532—85025005</p>
            <p class="footer-class" style="font-size:15px;margin-top: -75px;">地址:山东省青岛市市南区中联创意广场B1栋三楼 <a href="http://w3layouts.com/" target="_blank">万码学堂</a></p>
            <p class="footer-class" style="font-size:15px;margin-top: -60px;text-transform: none;">Copyright © 2019 www.dengnihuijia.com All rights Reserved.</p>
        </div>
    </div>
</footer>

<script src="<%=path%>/web/static/js/modules/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/web/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="${pageContext.request.contextPath}/web/ueditor/ueditor.all.js"></script>
<!-- 实例化编辑器 -->
</body>
</html>
<script type="text/javascript">
    //在线编译器;
    var ue = UE.getEditor('info',{
        toolbars: [[
            'fullscreen', 'source', '|', 'undo', 'redo', '|',
            'bold',  '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
            'rowspacingtop', 'rowspacingbottom','|',
            'indent', '|',
            'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', 'imagenone', '|'
        ]]
    });


    <!--/在线编译器发布内容 -->
    $(function(){
        <!-- 图片上传加显示-->
        var input=document.getElementById("pic");
        input.onchange = function() {
            var rd = new FileReader();//创建文件读取对象
            var files = input.files[0];//获取file组件中的文件
            rd.readAsDataURL(files);//文件读取装换为base64类型
            rd.onloadend = function (e) {
                //加载完毕之后获取结果赋值给img
                document.getElementById("showPic").src = this.result;
            }
        }
        <!-- /图片上传加显示-->
        var error_biaoti = false;//标题
        var error_title = false;//内容
        $(".tit").blur(function () {//标题失去焦点事件
            check_user_biaoti1()
        })
        $(".texts").blur(function () {//内容失去焦点事件
            check_user_neirong1()
        })
        function check_user_biaoti1() {//标题失去焦点事件
            var biaoti = $("#titles").val();
            if (biaoti == "") {
                $("#biaotiss").html("标题不能为空");
                $("#biaotiss").css("color", "red");
                error_biaoti = true;
            } else {
                error_biaoti = false;
                $("#biaotiss").html("");
            }
        }
        function check_user_neirong1() {//内容失去焦点事件
            var values = ue.getContentTxt();
            if (values == "") {
                $("#neirongs").html("内容不能为空");
                $("#neirongs").css("color", "red");
                error_title = true;
            } else {
                $("#neirongs").html("");
                error_title = false;
            }
        }
        $("#registers").submit(function () {
            check_user_biaoti1();
            check_user_neirong1();
            if (error_biaoti == false && error_title == false) {
                return true;
            } else {
                return false;
            }
        })
    });
</script>
